package znbkSameQuesTranslate;

import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.znbk.znbklibrary.base.AnswerViewPagerAdapter;
import com.example.znbk.znbklibrary.base.BaseFragment;
import com.example.znbk.znbklibrary.base.BaseFragmentPagerAdapter;
import com.example.znbk.znbklibrary.base.BaseLongActivity;
import com.example.znbk.znbklibrary.dialog.LoadingDialog;
import com.example.znbk.znbklibrary.util.LancooUtils;
import com.example.znbk.znbklibrary.widget.ControlScrollViewPager;
import com.example.znbk.znbklibrary.widget.ScaleButton;
import com.google.gson.Gson;
import com.lancoo.znbkxx.R;
import com.lancoo.znbkxx.beans.UserInfoBean;
import com.lancoo.znbkxx.net.URLConstant;

import java.util.ArrayList;
import java.util.List;

import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import znbkBkfx.AboutKnowledgePoint.HighLightKeyWordUtil;
import znbkBkfx.PostCollectionJson.PostCollectionJson;
import znbkBkfx.PostCollectionJson.PostCollection_interface;
import znbkCNtxl.CNtxlActivity;
import znbkSameQuesTranslate.GetSameQuesJson.PostRequest_SameQuesInterface;
import znbkSameQuesTranslate.GetSameQuesJson.PostSameQuesJsonBody;
import znbkSameQuesTranslate.GetSameQuesJson.SameQuesInitParam;
import znbkSameQuesTranslate.GetSameQuesJson.SameQuesPaperEntity;
import znbkSameQuesTranslate.PostSaveSQxlAnswer.PostSubmitKgtRecommendQuesAnswer_Interface;
import znbkSameQuesTranslate.PostSaveSQxlAnswer.SaveQuesAnswerModel_sq;
import znbkSameQuesTranslate.PostSaveSQxlAnswer.SaveResultJson;
import znbkSameQuesTranslate.SQ_DXT.SQxlDxtAnswerAdapter;
import znbkSameQuesTranslate.SQ_DXT.SQxlDxtFragment;
import znbkSameQuesTranslate.SQ_PPT.SQxlPptFragment;
import znbkSameQuesTranslate.SQ_TKT.SQxlTktFragment;
import znbkSameQuesTranslate.SQ_TLTK.SQxlTltkFragment;
import znbkSameQuesTranslate.SQ_TLXZ.SQxlTlxzAnswerAdapter;
import znbkSameQuesTranslate.SQ_TLXZ.SQxlTlxzFragment;
import znbkSameQuesTranslate.SQ_WXXZ.SQxlWxxzFragment;
import znbkSameQuesTranslate.SQ_YDJD.SQxlYdjdFragment;
import znbkSameQuesTranslate.SQ_YDXZ.SQxlYdxzFragment;

public class SameQuesActivity extends BaseLongActivity {


    private List<SameQuesPaperEntity> sameQuesPaperEntity;
    private void getPaperInfor() {
        PostSameQuesJsonBody postSameQuesJsonBody =new PostSameQuesJsonBody();
        postSameQuesJsonBody.setKey(UserInfoBean.Key);
        postSameQuesJsonBody.setCourseClassID(UserInfoBean.CourseClassID);
        postSameQuesJsonBody.setGlobalGrade(UserInfoBean.GlobalGrade);
        postSameQuesJsonBody.setReplaceBlank(true);
        postSameQuesJsonBody.setReplaceUrl(true);
        postSameQuesJsonBody.setSchoolID(UserInfoBean.SchoolID);
        postSameQuesJsonBody.setStageNo(UserInfoBean.StageNo);
        postSameQuesJsonBody.setStuID(UserInfoBean.StuId);
        postSameQuesJsonBody.setSubjectID(UserInfoBean.SubjectID);
        postSameQuesJsonBody.setGenreID(SameQuesInitParam.SQ_GenreID);
        postSameQuesJsonBody.setHval(SameQuesInitParam.SQ_Hval);
        postSameQuesJsonBody.setImportKnCode(SameQuesInitParam.SQ_ImportKnCode);
        postSameQuesJsonBody.setQuesID(SameQuesInitParam.SQ_QuesID);
        postSameQuesJsonBody.setQuesTypeID(SameQuesInitParam.SQ_QuesTypeID);

        Gson gson=new Gson();
        String BODY= gson.toJson(postSameQuesJsonBody);
        Log.e("==BODY_CNTXL=","========BODY====请求参数(错难题)============="+BODY);
        String BASE_URL = URLConstant.BASE_URL;
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory( GsonConverterFactory.create())
                .build();
        PostRequest_SameQuesInterface postRequest = retrofit.create(PostRequest_SameQuesInterface.class);
        RequestBody body=RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),BODY);
        Call<List<SameQuesPaperEntity>> call = postRequest.getSameQuesPaperInfor(body);
        call.enqueue(new Callback<List<SameQuesPaperEntity>>() {
            @Override
            public void onResponse(Call<List<SameQuesPaperEntity>> call, Response<List<SameQuesPaperEntity>> response) {
                Log.e("onResponse==wwwwww=","===cntxlPaper=====http============="+response);
                sameQuesPaperEntity = response.body();
                Log.e("onResponse===AAAWAA=","======cntxlPaper=========json============="+sameQuesPaperEntity);
                if(sameQuesPaperEntity.size()==0){
                    LancooUtils.showShort(SameQuesActivity.this,"数据有误");
                    mIvNoPaper.setVisibility(View.VISIBLE);
                }else {
                    showPaperFragmentDetails();
                }
                mLoadingDialog.dismiss();
            }

            @Override
            public void onFailure(Call<List<SameQuesPaperEntity>> call, Throwable t) {
                Log.e("onFailure", t.getMessage());
                mIvNoPaper.setVisibility(View.VISIBLE);
                mLoadingDialog.dismiss();
            }
        });

    }

    @Override
    protected int setLayout() {
        return R.layout.activity_same_ques_paper;
    }

    private int currentPageIndex = 0;//记录当前试题页的地址页码
    private LoadingDialog mLoadingDialog;
    private RelativeLayout mRlControlView;
    private ScaleButton mSBtnBack;//返回按钮
    private TextView mTvPracticeName;//练习名称
    private ScaleButton mSBtnAnswerNote;//笔记按钮
    private ScaleButton mSBtnAnswerCollection;//收藏按钮
    private TextView mTvQuesInfor;//试题信息
    public static ControlScrollViewPager mVpSameQues;
    private ImageView mIvNoPaper;
    private List<BaseFragment> mFragmentList;
    private BaseFragmentPagerAdapter mNtxlFragmentAdapter;
    @Override
    protected void initView() {

        currentPageIndex = 0;
        mLoadingDialog = new LoadingDialog(this,false,false,"难题加载中");
        mLoadingDialog.show();

        mSBtnBack = findViewById(R.id.sbtn_back);
        mSBtnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        mTvPracticeName = findViewById(R.id.tv_practiceName);
        mTvPracticeName.setText("同类题练习");
        mSBtnAnswerNote = findViewById(R.id.sbtn_answerNote);
        mSBtnAnswerCollection = findViewById(R.id.sbtn_answerCollection);

        mTvQuesInfor = findViewById(R.id.tv_quesInfor);
        mVpSameQues =  findViewById(R.id.vp_sameQues);
        mIvNoPaper = findViewById(R.id.iv_noPaper);
        mIvNoPaper.setVisibility(View.GONE);

        getPaperInfor();

    }

    @Override
    public void onBackPressed() {
        finish();
    }

    private void showPaperFragmentDetails(){
        final String TypeNo = sameQuesPaperEntity.get(currentPageIndex).getQuesFromTK().getTypeInfo().getTypeNo();
        final int PaperListSize = sameQuesPaperEntity.size();

        mTvQuesInfor.setText(Html.fromHtml(getResources().getString(R.string.ntxl_paper_infor, "同类题", 1, PaperListSize)));

        mFragmentList = new ArrayList<>();
        mFragmentList.clear();

        for(int i=0;i<PaperListSize;i++) {
            if(TypeNo.equals("A")) {
                final int finalI = i;
                mFragmentList.add(new SQxlDxtFragment(sameQuesPaperEntity, i, new SQxlDxtFragment.CallBackFragmentDxt() {
                    @Override
                    public void submitKgtQuesAnswer() {
//                      SubmitCntxlKgtQuesAnswer(currentPageIndex);

//                        doRefreshCurrentPageView(finalI);
//                        mVpSameQues.setScrollble(true);

                        if((finalI+1)<PaperListSize){
                            mVpSameQues.setCurrentItem(finalI+1);
                        }else{
                            LancooUtils.showShort(SameQuesActivity.this,"已是最后一题");
                        }

                    }
                }));
            }else if(TypeNo.equals("E")){
                final int finalI = i;
                mFragmentList.add(new SQxlTlxzFragment(sameQuesPaperEntity, i, new SQxlTlxzFragment.CallBackFragmentTlxz() {
                    @Override
                    public void submitKgtQuesAnswer() {
//                      SubmitCntxlKgtQuesAnswer(currentPageIndex);

//                        doRefreshCurrentPageView(finalI);
//                        mVpSameQues.setScrollble(true);

                        if((finalI+1)<PaperListSize){
                            mVpSameQues.setCurrentItem(finalI+1);
                        }else{
                            LancooUtils.showShort(SameQuesActivity.this,"已是最后一题");
                        }

                    }
                }));
            }else if(TypeNo.equals("D")){
                final int finalI = i;
                mFragmentList.add(new SQxlYdxzFragment(sameQuesPaperEntity, i, new SQxlYdxzFragment.CallBackFragmentYdxz() {
                    @Override
                    public void submitKgtQuesAnswer() {
//                      SubmitCntxlKgtQuesAnswer(currentPageIndex);

//                        doRefreshCurrentPageView(finalI);
//                        mVpSameQues.setScrollble(true);

                        if((finalI+1)<PaperListSize){
                            mVpSameQues.setCurrentItem(finalI+1);
                        }else{
                            LancooUtils.showShort(SameQuesActivity.this,"已是最后一题");
                        }

                    }
                }));
            }else if(TypeNo.equals("N")||TypeNo.equals("Q")){
                mFragmentList.add(new SQxlTktFragment(sameQuesPaperEntity, i, new SQxlTktFragment.CallBackFragmentTkt() {
                    @Override
                    public void submitKgtQuesAnswer() {
//                        SubmitCntxlKgtQuesAnswer(currentPageIndex);
//
//                        boolean isCanMovePaper = true;
//                        String GenreName = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getGenreInfo().getGenreName();
//                        if(GenreName.equals("选词填空")){
//                            int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
//                            for(int i=0;i<Size;i++){
//                                String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
//                                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
//                                String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
//                                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
//                                if(!ItemAnswer.equals(StuAnswer)){
//                                    isCanMovePaper = false;
//                                    break;
//                                }
//                            }
//                        }else{
//                            int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().
//                                    get(0).getSubChildList().get(0).getSubChildItem().size();
//                            for(int i=0;i<Size;i++){
//                                String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
//                                        get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
//                                String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
//                                        get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
//                                if(!ItemAnswer.equals(StuAnswer)){
//                                    isCanMovePaper = false;
//                                    break;
//                                }
//                            }
//                        }
//
//                        if(isCanMovePaper) {
//                            if ((currentPageIndex + 1) < PaperListSize) {
//                                mVpCNtxl.setCurrentItem(currentPageIndex + 1);
//                            }else {
//                                LancooUtils.showShort(CNtxlActivity.this, "没有更多题目了");
//                            }
//                        }else{
//                            LancooUtils.showShort(CNtxlActivity.this, "做得太糟了...");
//                            CNtxlTktFragment fragment = (CNtxlTktFragment) mFragmentList.get(currentPageIndex);
//                            mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
//                            mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
//                            mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
//                                @Override
//                                public void onClick(View v) {
//                                    LancooUtils.showShort(CNtxlActivity.this,"进入听力填空同类题训练");
//                                }
//                            });
//
//                            if(PhoneMainActivity.getCNtxlModel()==1) {
//                                showSameQuesTranslateView();
//                            }
//                        }
//                        mVpCNtxl.setScrollble(true);
                    }

                }));
            }if(TypeNo.equals("S")) {
                mFragmentList.add(new SQxlTltkFragment( sameQuesPaperEntity, i, new SQxlTltkFragment.CallBackFragmentTltk() {
                    @Override
                    public void submitKgtQuesAnswer() {
//                        SubmitCntxlKgtQuesAnswer(currentPageIndex);
//
//                        boolean isCanMovePaper = true;
//                        int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().
//                                get(0).getSubChildList().get(0).getSubChildItem().size();
//                        for(int i=0;i<Size;i++){
//                            String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
//                                    get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
//                            String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
//                                    get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
//                            if(!ItemAnswer.equals(StuAnswer)){
//                                isCanMovePaper = false;
//                                break;
//                            }
//                        }
//                        if(isCanMovePaper) {
//                            if ((currentPageIndex + 1) < PaperListSize) {
//                                mVpCNtxl.setCurrentItem(currentPageIndex + 1);
//                            }else {
//                                LancooUtils.showShort(CNtxlActivity.this, "没有更多题目了");
//                            }
//                        }else{
//                            LancooUtils.showShort(CNtxlActivity.this, "做得太糟了...");
//                            CNtxlTltkFragment fragment = (CNtxlTltkFragment) mFragmentList.get(currentPageIndex);
//                            mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
//                            mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
//                            mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
//                                @Override
//                                public void onClick(View v) {
//                                    LancooUtils.showShort(CNtxlActivity.this,"进入听力填空同类题训练");
//                                    setSameQuesInitParma();
//                                }
//                            });
//
//                            if(PhoneMainActivity.getCNtxlModel()==1) {
//                                showSameQuesTranslateView();
//                            }
//                        }
//                        mVpCNtxl.setScrollble(true);
                    }
                }));
            }else if(TypeNo.equals("b")||TypeNo.equals("d")||TypeNo.equals("X")||TypeNo.equals("g")||TypeNo.equals("V")){
                mFragmentList.add(new SQxlYdjdFragment(sameQuesPaperEntity, i, new SQxlYdjdFragment.CallBackFragmentYdjd() {

                    @Override
                    public void submitZgtQuesAnswer() {
//                        SubmitSQxlZgtQuesAnswer(currentPageIndex);
                    }

                }));
            }else if(TypeNo.equals("C")){
                mFragmentList.add(new SQxlWxxzFragment(sameQuesPaperEntity, i, new SQxlWxxzFragment.CallBackFragmentWxxz() {

                    @Override
                    public void submitKgtQuesAnswer() {

                    }

                }));
            }  mFragmentList.add(new SQxlPptFragment(sameQuesPaperEntity,i, new SQxlPptFragment.CallBackFragmentPpt() {
                @Override
                public void pageMoveNext() {
                    if ((currentPageIndex + 1) < PaperListSize) {
                        mVpSameQues.setCurrentItem(currentPageIndex + 1);
                    } else {
                        Log.e("==mFragmentList==", "==========E==========没有更多题目了=============");
                        Toast.makeText(SameQuesActivity.this, "没有更多题目了", Toast.LENGTH_SHORT).show();
                    }
                }
            }));

        }
        mNtxlFragmentAdapter = new BaseFragmentPagerAdapter(getSupportFragmentManager(), mFragmentList);
        mVpSameQues.setAdapter(mNtxlFragmentAdapter);
        mVpSameQues.setCurrentItem(0);
        showCollectionInfor(0);
        showAnswerNoteInfor(0);
        mVpSameQues.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }
            @Override
            public void onPageSelected(int position) {

                mVpSameQues.setScrollble(false);
                final Handler mH = new Handler();
                mH.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mVpSameQues.setScrollble(true);
                        mH.removeCallbacks(this);
                    }
                },800);

                showCollectionInfor(position);//刷新收藏情况
                showAnswerNoteInfor(position);//刷新笔记按钮

                int SubmitState  = sameQuesPaperEntity.get(currentPageIndex).getFavouriteAndNote().getSubmitState();
                if(SubmitState!=2) {
                    if (position > currentPageIndex) {
                        sameQuesPaperEntity.get(currentPageIndex).getFavouriteAndNote().setSubmitState(2);
                        doRefreshCurrentPageView(currentPageIndex);
                    }
                }

                currentPageIndex = position;
                mTvQuesInfor.setText(Html.fromHtml(getResources().getString(R.string.ntxl_paper_infor,"同类题",(position+1),PaperListSize)));
            }
            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

    }

    /*
    * 收藏相关
    * */
    private void showCollectionInfor(final int position){
        boolean IsFavourite = sameQuesPaperEntity.get(position).getFavouriteAndNote().isIsFavourite();
        if(IsFavourite) {
            // 使用代码设置drawableleft
            Drawable drawable = getResources().getDrawable(R.mipmap.topbar_icon_collection_select);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight());//这一步必须要做,否则不会显示.
            mSBtnAnswerCollection.setCompoundDrawables(drawable, null, null, null);
        }else{
            // 使用代码设置drawableleft
            Drawable drawable = getResources().getDrawable(R.mipmap.topbar_icon_collection_unselect);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight());//这一步必须要做,否则不会显示.
            mSBtnAnswerCollection.setCompoundDrawables(drawable, null, null, null);
        }
        mSBtnAnswerCollection.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean IsFavourite = sameQuesPaperEntity.get(position).getFavouriteAndNote().isIsFavourite();
                if(IsFavourite){
                    postCollection(position,0);
                    sameQuesPaperEntity.get(position).getFavouriteAndNote().setIsFavourite(false);
                    Drawable drawable = getResources().getDrawable(R.mipmap.topbar_icon_collection_unselect);
                    drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight());//这一步必须要做,否则不会显示.
                    mSBtnAnswerCollection.setCompoundDrawables(drawable, null, null, null);
                }else{
                    postCollection(position,1);
                    sameQuesPaperEntity.get(position).getFavouriteAndNote().setIsFavourite(true);
                    Drawable drawable = getResources().getDrawable(R.mipmap.topbar_icon_collection_select);
                    drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight());//这一步必须要做,否则不会显示.
                    mSBtnAnswerCollection.setCompoundDrawables(drawable, null, null, null);
                }
            }
        });
    }

    /*
     * 笔记相关
     * */
    private void showAnswerNoteInfor(final int position){
        mSBtnAnswerNote.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LancooUtils.showShort(SameQuesActivity.this,"笔记功能暂未开放");
            }
        });
    }

    /*
     * 收藏Post请求
     * */
    private void postCollection(int position,int collectionFlag) {

        String QuesBreaf = sameQuesPaperEntity.get(position).getQuesFromTK().getQuesBrief();
        String QuesID = sameQuesPaperEntity.get(position).getQuesFromTK().getQuesID();
        String TypeNo = sameQuesPaperEntity.get(position).getQuesFromTK().getTypeInfo().getTypeNo();
        String GenreID = sameQuesPaperEntity.get(position).getQuesFromTK().getGenreInfo().getGenreID();

        PostCollectionJson postCollectionJson =new PostCollectionJson();
        postCollectionJson.setKey(UserInfoBean.Key);
        postCollectionJson.setCourseClassID(UserInfoBean.CourseClassID);
        postCollectionJson.setFlag(collectionFlag);
        postCollectionJson.setGenreID(GenreID);
        postCollectionJson.setGlobalGrade(UserInfoBean.GlobalGrade);
        postCollectionJson.setQuesBrief(QuesBreaf);
        postCollectionJson.setQuesID(QuesID);
        postCollectionJson.setTypeNo(TypeNo);
        postCollectionJson.setSchoolID(UserInfoBean.SchoolID);
        postCollectionJson.setStuID(UserInfoBean.StuId);
        postCollectionJson.setSubjectID(UserInfoBean.SubjectID);
        Gson gson=new Gson();
        String BODY= gson.toJson(postCollectionJson);
        Log.e("==BODY_ABCD=","========BODY====请求参数============="+BODY);
        String BASE_URL = URLConstant.BASE_URL;
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory( GsonConverterFactory.create())
                .build();
        PostCollection_interface postRequest = retrofit.create(PostCollection_interface.class);
        RequestBody body=RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),BODY);
        Call<Integer> call = postRequest.postCollection(body);
        call.enqueue(new Callback<Integer>() {
            @Override
            public void onResponse(Call<Integer> call, Response<Integer> response) {
                String result = response.body().toString();
                Log.e("onResponse=","===============成功============="+result);
            }

            @Override
            public void onFailure(Call<Integer> call, Throwable t) {
                Log.e("onFailure", t.getMessage());
            }
        });

    }


    //提交客观题作答信息
    private void SubmitSQxlKgtQuesAnswer(int position) {

        double CorrectRate = 0;
        List<SaveQuesAnswerModel_sq.ChildListBean> ChildList = new ArrayList<>();
        String TypeNo = sameQuesPaperEntity.get(position).getQuesFromTK().getTypeInfo().getTypeNo();
        if(TypeNo.equals("A")||TypeNo.equals("E")||TypeNo.equals("D")){

            int AnsweredCountTrue = 0;
            int ChildListSize =  sameQuesPaperEntity.get(position).getQuesFromTK().getChildList().size();
            for(int i=0;i<ChildListSize;i++) {
                SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean subChildItemBean =
                        new SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean();
                String AudioPath =  sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getAudioPath();
                String ImagePath = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getImagePath();
                String ItemAnswer = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                int ItemIndex = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemIndex();
                String StuAnswer = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                subChildItemBean.setAudioPath(AudioPath);
                subChildItemBean.setImagePath(ImagePath);
                subChildItemBean.setItemAnswer(ItemAnswer);
                subChildItemBean.setItemIndex(ItemIndex);
                subChildItemBean.setScoreRate(0);
                subChildItemBean.setStuAnswer(StuAnswer);
                List<SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItem = new ArrayList<>();
                SubChildItem.add(subChildItemBean);

                SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean subChildListBean =
                        new SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean();
                int SubChildIndex = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).
                        getSubChildList().get(0).getSubChildIndex();
                subChildListBean.setSubChildIndex(SubChildIndex);
                subChildListBean.setSubChildItem(SubChildItem);
                List<SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
                SubChildList.add(subChildListBean);

                SaveQuesAnswerModel_sq.ChildListBean childListBean =
                        new SaveQuesAnswerModel_sq.ChildListBean();
                int ChildIndex = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).getChildIndex();
                childListBean.setChildIndex(ChildIndex);
                childListBean.setSubChildList(SubChildList);

                ChildList.add(childListBean);

                if(ItemAnswer.equals(StuAnswer)){
                    AnsweredCountTrue = AnsweredCountTrue+1;
                }

            }
            int QuesAnswerSize = sameQuesPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
            CorrectRate = LancooUtils.getCorrectRate(AnsweredCountTrue,QuesAnswerSize);

        }else if(TypeNo.equals("S")||TypeNo.equals("N")||TypeNo.equals("Q")){

            String GenreName = sameQuesPaperEntity.get(position).getQuesFromTK().getGenreInfo().getGenreName();
            if(GenreName.equals("选词填空")){
                int AnsweredCountTrue = 0;
                int ChildListSize =  sameQuesPaperEntity.get(position).getQuesFromTK().getChildList().size();
                for(int i=0;i<ChildListSize;i++) {
                    SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean subChildItemBean =
                            new SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean();
                    String AudioPath =  sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getAudioPath();
                    String ImagePath = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getImagePath();
                    String ItemAnswer = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                    int ItemIndex = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemIndex();
                    String StuAnswer = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                    subChildItemBean.setAudioPath(AudioPath);
                    subChildItemBean.setImagePath(ImagePath);
                    subChildItemBean.setItemAnswer(ItemAnswer);
                    subChildItemBean.setItemIndex(ItemIndex);
                    subChildItemBean.setScoreRate(0);
                    subChildItemBean.setStuAnswer(StuAnswer);
                    List<SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItem = new ArrayList<>();
                    SubChildItem.add(subChildItemBean);

                    SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean subChildListBean =
                            new SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean();
                    int SubChildIndex = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).
                            getSubChildList().get(0).getSubChildIndex();
                    subChildListBean.setSubChildIndex(SubChildIndex);
                    subChildListBean.setSubChildItem(SubChildItem);
                    List<SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
                    SubChildList.add(subChildListBean);

                    SaveQuesAnswerModel_sq.ChildListBean childListBean =
                            new SaveQuesAnswerModel_sq.ChildListBean();
                    int ChildIndex = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).getChildIndex();
                    childListBean.setChildIndex(ChildIndex);
                    childListBean.setSubChildList(SubChildList);

                    ChildList.add(childListBean);

                    if(ItemAnswer.equals(StuAnswer)){
                        AnsweredCountTrue = AnsweredCountTrue+1;
                    }

                }
                int QuesAnswerSize = sameQuesPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
                CorrectRate = LancooUtils.getCorrectRate(AnsweredCountTrue,QuesAnswerSize);
            }else{
                int AnsweredCountTrue = 0;
                List<SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItem = new ArrayList<>();
                int Size =  sameQuesPaperEntity.get(position).getQuesFromTK().getChildList().get(0).getSubChildList().get(0).getSubChildItem().size();
                for(int i=0;i<Size;i++) {
                    SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean subChildItemBean =
                            new SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean();
                    String AudioPath = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getAudioPath();
                    String ImagePath = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getImagePath();
                    String ItemAnswer = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
                    int ItemIndex = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemIndex();
                    String StuAnswer = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
                    subChildItemBean.setAudioPath(AudioPath);
                    subChildItemBean.setImagePath(ImagePath);
                    subChildItemBean.setItemAnswer(ItemAnswer);
                    subChildItemBean.setItemIndex(ItemIndex);
                    subChildItemBean.setScoreRate(0);
                    subChildItemBean.setStuAnswer(StuAnswer);

                    if(ItemAnswer.equals(StuAnswer)){
                        AnsweredCountTrue = AnsweredCountTrue+1;
                    }

                    SubChildItem.add(subChildItemBean);
                }

                SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean subChildListBean =
                        new SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean();
                int SubChildIndex = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().get(0).
                        getSubChildList().get(0).getSubChildIndex();
                subChildListBean.setSubChildIndex(SubChildIndex);
                subChildListBean.setSubChildItem(SubChildItem);
                List<SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
                SubChildList.add(subChildListBean);

                SaveQuesAnswerModel_sq.ChildListBean childListBean =
                        new SaveQuesAnswerModel_sq.ChildListBean();
                int ChildIndex = sameQuesPaperEntity.get(position).getFavouriteAndNote().getChildList().get(0).getChildIndex();
                childListBean.setChildIndex(ChildIndex);
                childListBean.setSubChildList(SubChildList);

                ChildList.add(childListBean);

                int QuesAnswerSize = sameQuesPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
                CorrectRate = LancooUtils.getCorrectRate(AnsweredCountTrue,QuesAnswerSize);
            }
        }

        SaveQuesAnswerModel_sq mSaveQuesAnswerModel_sq = new SaveQuesAnswerModel_sq();
        String GenreID = sameQuesPaperEntity.get(position).getQuesFromTK().getGenreInfo().getGenreID();
        String QuesID = sameQuesPaperEntity.get(position).getQuesFromTK().getQuesID();
        mSaveQuesAnswerModel_sq.setChildList(ChildList);
        mSaveQuesAnswerModel_sq.setCorrectRate(CorrectRate);
        mSaveQuesAnswerModel_sq.setCourseClassID(UserInfoBean.CourseClassID);
        mSaveQuesAnswerModel_sq.setDuration(10);//待传（需计算）
        mSaveQuesAnswerModel_sq.setGenreID(GenreID);
        mSaveQuesAnswerModel_sq.setGlobalGrade(UserInfoBean.GlobalGrade);
        mSaveQuesAnswerModel_sq.setItemType(2);//1--错题；3--难题
        mSaveQuesAnswerModel_sq.setQuesID(QuesID);
        mSaveQuesAnswerModel_sq.setSchoolID(UserInfoBean.SchoolID);
        mSaveQuesAnswerModel_sq.setStuID(UserInfoBean.StuId);
        mSaveQuesAnswerModel_sq.setState(2);
        mSaveQuesAnswerModel_sq.setTypeNo(TypeNo);
        mSaveQuesAnswerModel_sq.setSubjectID(UserInfoBean.SubjectID);
        mSaveQuesAnswerModel_sq.setKey(UserInfoBean.Key);
        mSaveQuesAnswerModel_sq.setMistakeQuesID(SameQuesInitParam.SQ_QuesID);


        Gson gson=new Gson();
        String BODY= gson.toJson(mSaveQuesAnswerModel_sq);
        Log.e("==BODYAABB=","========BODY====请求参数=====AAAAA=============="+BODY);
        String BASE_URL = URLConstant.BASE_URL;
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory( GsonConverterFactory.create())
                .build();
        PostSubmitKgtRecommendQuesAnswer_Interface postRequest = retrofit.create(PostSubmitKgtRecommendQuesAnswer_Interface.class);
        RequestBody body=RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),BODY);
        Call<SaveResultJson> call = postRequest.saveRecommendItemAnswer(body);
        call.enqueue(new Callback<SaveResultJson>() {
            @Override
            public void onResponse(Call<SaveResultJson> call, Response<SaveResultJson> response) {
                Log.e("onResponseAbc=","===============成功============="+response.body().isResult());
            }

            @Override
            public void onFailure(Call<SaveResultJson> call, Throwable t) {
                Log.e("onFailure", t.getMessage());
            }
        });

    }

    //提交大数据评阅作答信息
//    private boolean isCouldMoveNextPage_zgt = false;
//    private void SubmitCntxlZgtQuesAnswer(int position) {
//
//        mLoadingDialog = new LoadingDialog(this,false,false,"智能评测中...");
//        mLoadingDialog.show();
//
//        List<SaveQuesAnswerModel_sq.ChildListBean> ChildList = new ArrayList<>();
//        String TypeNo = CNtxlPaperEntity.get(position).getQuesFromTK().getTypeInfo().getTypeNo();
//        if(TypeNo.equals("f")||TypeNo.equals("V")||TypeNo.equals("X")||TypeNo.equals("d")||TypeNo.equals("g")){
//
//            int ChildListSize =  CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
//            for(int i=0;i<ChildListSize;i++) {
//                SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean subChildItemBean =
//                        new SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean();
//                String AudioPath =  CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
//                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getAudioPath();
//                String ImagePath = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
//                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getImagePath();
//                String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
//                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
//                int ItemIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
//                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemIndex();
//                String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
//                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
//                subChildItemBean.setAudioPath(AudioPath);
//                subChildItemBean.setImagePath(ImagePath);
//                subChildItemBean.setItemAnswer(ItemAnswer);
//                subChildItemBean.setItemIndex(ItemIndex);
//                subChildItemBean.setScoreRate(0);
//                subChildItemBean.setStuAnswer(StuAnswer);
//                List<SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItem = new ArrayList<>();
//                SubChildItem.add(subChildItemBean);
//
//                SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean subChildListBean =
//                        new SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean();
//                int SubChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).
//                        getSubChildList().get(0).getSubChildIndex();
//                subChildListBean.setSubChildIndex(SubChildIndex);
//                subChildListBean.setSubChildItem(SubChildItem);
//                List<SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
//                SubChildList.add(subChildListBean);
//
//                SaveQuesAnswerModel_sq.ChildListBean childListBean =
//                        new SaveQuesAnswerModel_sq.ChildListBean();
//                int ChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).getChildIndex();
//                childListBean.setChildIndex(ChildIndex);
//                childListBean.setSubChildList(SubChildList);
//
//                ChildList.add(childListBean);
//
//            }
//
//        }else if(TypeNo.equals("b")||TypeNo.equals("k")){
//            int ChildListSize = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
//            for(int i=0;i<ChildListSize;i++) {
//
//                List<SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItem = new ArrayList<>();
//                int SubChildItemSize = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().
//                        get(i).getSubChildList().get(0).getSubChildItem().size();
//                for(int j=0;j<SubChildItemSize;j++){
//                    SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean subChildItemBean =
//                            new SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean.SubChildItemBean();
//                    String AudioPath = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
//                            get(i).getSubChildList().get(0).getSubChildItem().get(j).getAudioPath();
//                    String ImagePath = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
//                            get(i).getSubChildList().get(0).getSubChildItem().get(j).getImagePath();
//                    String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
//                            get(i).getSubChildList().get(0).getSubChildItem().get(j).getItemAnswer();
//                    int ItemIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
//                            get(i).getSubChildList().get(0).getSubChildItem().get(j).getItemIndex();
//                    String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
//                            get(i).getSubChildList().get(0).getSubChildItem().get(j).getStuAnswer();
//
//                    double ScoreRate = 0;
//                    String[] ItemAnswerArray = LancooUtils.returnArray(ItemAnswer,"$/",2);
//                    List<String> list=Arrays.asList(ItemAnswerArray);
//                    if(list.contains(StuAnswer)){
//                        ScoreRate = 1;
//                    }
//
//                    subChildItemBean.setAudioPath(AudioPath);
//                    subChildItemBean.setImagePath(ImagePath);
//                    subChildItemBean.setItemAnswer(ItemAnswer);
//                    subChildItemBean.setItemIndex(ItemIndex);
//                    subChildItemBean.setScoreRate(ScoreRate);
//                    subChildItemBean.setStuAnswer(StuAnswer);
//
//                    SubChildItem.add(subChildItemBean);
//                }
//
//                SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean subChildListBean =
//                        new SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean();
//                int SubChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).
//                        getSubChildList().get(0).getSubChildIndex();
//                subChildListBean.setSubChildIndex(SubChildIndex);
//                subChildListBean.setSubChildItem(SubChildItem);
//                List<SaveQuesAnswerModel_sq.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
//                SubChildList.add(subChildListBean);
//
//                SaveQuesAnswerModel_sq.ChildListBean childListBean =
//                        new SaveQuesAnswerModel_sq.ChildListBean();
//                int ChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).getChildIndex();
//                childListBean.setChildIndex(ChildIndex);
//                childListBean.setSubChildList(SubChildList);
//
//                ChildList.add(childListBean);
//
//            }
//        }
//
//        SaveQuesAnswerModel_sq mSaveQuesAnswerModel_sq = new SaveQuesAnswerModel_sq();
//        String GenreID = CNtxlPaperEntity.get(position).getQuesFromTK().getGenreInfo().getGenreID();
//        String QuesID = CNtxlPaperEntity.get(position).getQuesFromTK().getQuesID();
//        mSaveQuesAnswerModel_sq.setChildList(ChildList);
//        mSaveQuesAnswerModel_sq.setCorrectRate(0);
//        mSaveQuesAnswerModel_sq.setCourseClassID(UserInfoBean.CourseClassID);
//        mSaveQuesAnswerModel_sq.setDuration(10);//待传（需计算）
//        mSaveQuesAnswerModel_sq.setGenreID(GenreID);
//        mSaveQuesAnswerModel_sq.setGlobalGrade(UserInfoBean.GlobalGrade);
//        mSaveQuesAnswerModel_sq.setItemType(ItemType);//1--错题；3--难题
//        mSaveQuesAnswerModel_sq.setQuesID(QuesID);
//        mSaveQuesAnswerModel_sq.setSchoolID(UserInfoBean.SchoolID);
//        mSaveQuesAnswerModel_sq.setStuID(UserInfoBean.StuId);
//        mSaveQuesAnswerModel_sq.setState(0);
//        mSaveQuesAnswerModel_sq.setTypeNo(TypeNo);
//        mSaveQuesAnswerModel_sq.setSubjectID(UserInfoBean.SubjectID);
//        mSaveQuesAnswerModel_sq.setKey(UserInfoBean.Key);
//
//        Gson gson=new Gson();
//        String BODY= gson.toJson(mSaveQuesAnswerModel_sq);
//        Log.e("==BODYAABB=","========BODY====请求参数=====AAAAA=============="+BODY);
//        String BASE_URL = URLConstant.BASE_URL;
//        Retrofit retrofit=new Retrofit.Builder()
//                .baseUrl(BASE_URL)
//                .addConverterFactory( GsonConverterFactory.create())
//                .build();
//        PostSubmitZgtQuesAnswer_Interface postRequest = retrofit.create(PostSubmitZgtQuesAnswer_Interface.class);
//        RequestBody body=RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),BODY);
//        Call<List<ResultZgtJson>> call = postRequest.submitCNtxlZgtQuesAnswer(body);
//        call.enqueue(new Callback<List<ResultZgtJson>>() {
//            @Override
//            public void onResponse(Call<List<ResultZgtJson>> call, Response<List<ResultZgtJson>> response) {
//
//                doRefreshCurrentPageView();
//                mLoadingDialog.dismiss();
//
//                Log.e("onResponse=","===============成功=====1111========"+response.body().get(0).getScoreRate());
//                int size = response.body().size();
//                final String TypeNo = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getTypeInfo().getTypeNo();
//                for(int i=0;i<size;i++){
//                    double ScoreRate = response.body().get(i).getScoreRate();
//                    if(TypeNo.equals("k")) {
//
//                    }else if(TypeNo.equals("b")){
//                        CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
//                                get(0).getSubChildList().get(0).getSubChildItem().get(i).setScoreRate(ScoreRate);
//                    }else{
//                        CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
//                                get(i).getSubChildList().get(0).getSubChildItem().get(0).setScoreRate(ScoreRate);
//                    }
//                }
//
//
//                isCouldMoveNextPage_zgt = true;
//                for(int i=0;i<size;i++){
//                    if(response.body().get(i).getScoreRate()<0.6){
//                        isCouldMoveNextPage_zgt = false;
//                        break;
//                    }
//                }
//
//                final Handler mH = new Handler();
//                mH.postDelayed(new Runnable() {
//                    @Override
//                    public void run() {
//                        if(isCouldMoveNextPage_zgt){
//                            int PageSize = CNtxlPaperEntity.size();
//                            if(currentPageIndex<PageSize-1){
//                                mVpCNtxl.setCurrentItem(currentPageIndex+1);
//                            }else{
//                                LancooUtils.showShort(CNtxlActivity.this,"没有更多题目了");
//                            }
//                        }else{
//                            if(TypeNo.equals("k")){
//                                CNtxlYdzhFragment fragment = (CNtxlYdzhFragment) mFragmentList.get(currentPageIndex);
//                                mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
//                                mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
//                                mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
//                                    @Override
//                                    public void onClick(View v) {
//                                        LancooUtils.showShort(CNtxlActivity.this, "进入阅读综合题同类题训练");
//                                    }
//                                });
//                            }else {
//                                CNtxlYdjdFragment fragment = (CNtxlYdjdFragment) mFragmentList.get(currentPageIndex);
//                                mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
//                                mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
//                                mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
//                                    @Override
//                                    public void onClick(View v) {
//                                        LancooUtils.showShort(CNtxlActivity.this, "进入简答题同类题训练");
//                                    }
//                                });
//                            }
//
//                            if(PhoneMainActivity.getCNtxlModel()==1) {
//                                showSameQuesTranslateView();
//                            }
//                        }
//                        mH.removeCallbacks(this);
//                    }
//                },1000);
//
//
//            }
//
//            @Override
//            public void onFailure(Call<List<ResultZgtJson>> call, Throwable t) {
//                Log.e("onFailure", t.getMessage());
//            }
//        });
//
//    }

    private void doRefreshCurrentPageView(int position){
        String TypeNo = sameQuesPaperEntity.get(position).getQuesFromTK().getTypeInfo().getTypeNo();
        //刷新上一页作答界面详情
        int SubmitState  = sameQuesPaperEntity.get(position).getFavouriteAndNote().getSubmitState();
        if(SubmitState==2) {

            if(TypeNo.equals("A")){

                SQxlDxtFragment fragment = (SQxlDxtFragment) mFragmentList.get(position);
                //显示刷新作答结果
                ArrayList<View> list = new ArrayList<>();
                list.clear();
                final RecyclerView mRvAnswer = new RecyclerView(SameQuesActivity.this);
                mRvAnswer.setLayoutManager(new LinearLayoutManager(SameQuesActivity.this));//必须先设置LayoutManager
                SQxlDxtAnswerAdapter mAnswerAdapter = new SQxlDxtAnswerAdapter(SameQuesActivity.this,
                        sameQuesPaperEntity,position,new SQxlDxtAnswerAdapter.CallBackAdapterDxt(){

                    @Override
                    public void callAnsweredAll() {

                    }


                });
                mRvAnswer.setAdapter(mAnswerAdapter);
                list.add(mRvAnswer);
                ViewPager mVpAnswer = fragment.getView().findViewById(R.id.vp_answerDxt);
                mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));

                SubmitSQxlKgtQuesAnswer(position);
            }else if(TypeNo.equals("E")){

                SQxlTlxzFragment fragment = (SQxlTlxzFragment) mFragmentList.get(position);
                RelativeLayout mRlMyBrowseBg = fragment.getView().findViewById(R.id.rl_myBrowseBg);
                mRlMyBrowseBg.setVisibility(View.GONE);
                RelativeLayout mRlMyRecordMiBg = fragment.getView().findViewById(R.id.rl_myRecordBg);
                mRlMyRecordMiBg.setVisibility(View.GONE);
                fragment.pause();
                //显示听力原文
                TextView mTvListenScript = fragment.getView().findViewById(R.id.tv_listenScript);
                mTvListenScript.setVisibility(View.VISIBLE);
                String ListenScript  = sameQuesPaperEntity.get(position).getQuesFromTK().getAudioList().get(0).getText();
                CharSequence ListenScriptA = Html.fromHtml("听力原文<br><br>"+ListenScript);
                int ImprotantZSDSize = sameQuesPaperEntity.get(position).getQuesFromTK().getImprotantZSD().size();
                String[] keyword = new String[ImprotantZSDSize];
                String[] keywordCode = new String[ImprotantZSDSize];
                for(int i=0;i<ImprotantZSDSize;i++){
                    keyword[i] = sameQuesPaperEntity.get(position).getQuesFromTK().getImprotantZSD().get(i).getName();
                    keywordCode[i] = sameQuesPaperEntity.get(position).getQuesFromTK().getImprotantZSD().get(i).getCode();
                }
                SpannableString highlightText = HighLightKeyWordUtil.highlight(ListenScriptA.toString(), keyword, keywordCode,"#FF0000");
                mTvListenScript.setText(highlightText);
                mTvListenScript.setMovementMethod(LinkMovementMethod.getInstance());//设置可点击状态

                //显示刷新作答结果
                ArrayList<View> list = new ArrayList<>();
                list.clear();
                int totalItemCount = sameQuesPaperEntity.get(position).getQuesFromTK().getChildList().size();
                for(int i=0;i<totalItemCount;i++) {
                    final RecyclerView mRvAnswer = new RecyclerView(SameQuesActivity.this);
                    mRvAnswer.setLayoutManager(new LinearLayoutManager(SameQuesActivity.this));//必须先设置LayoutManager
                    SQxlTlxzAnswerAdapter mCNtxlTlxzAnswerAdapter = new SQxlTlxzAnswerAdapter(SameQuesActivity.this,
                            sameQuesPaperEntity,position,i,new SQxlTlxzAnswerAdapter.CallBackAdapterTlxz() {
                        @Override
                        public void callAnsweredAll() {

                        }

                    });
                    mRvAnswer.setAdapter(mCNtxlTlxzAnswerAdapter);
                    list.add(mRvAnswer);
                }
                ViewPager mVpAnswer = fragment.getView().findViewById(R.id.vp_answerTlxz);
                mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));
                mVpAnswer.setCurrentItem( sameQuesPaperEntity.get(position).getFavouriteAndNote().getCurrentSubChildAnswerIndex());

                SubmitSQxlKgtQuesAnswer(position);
            }
        }
    }

}
